home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Split or Polarized Carets.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.1 KB  |  89 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17.  
  18. #include "SampleInterface.h"
  19.  
  20. short MyStrLen(char *x);
  21. static short MyStrLen(x)
  22. char    *x;
  23.     {
  24.     short c = 0;
  25.     while (*x++) c++;
  26.     return c;
  27.     }    /* MyStrLen */
  28.  
  29. static char arabicString[8] = {'\xE5', '\xC7', '\xE3', '\xE6', '\xCA', '\xE8', '\xD4', 0};
  30.  
  31. void SplitPolarizedCarets(WindowPtr sampleWindow)
  32.     {
  33.     /* Variables */
  34.     char        *romanString = "Mega";
  35.     gxPoint        myPoint;
  36.     gxShape        caret, layout;
  37.     short        len, level = 0, runLengths[2];
  38.     gxStyle        arabicStyle, romanStyle, styleArray[2];
  39.     gxViewPort    aViewPort;
  40.     void        *textPtrs[2];
  41.     
  42.     /* Initialization */
  43.     
  44.     myPoint.x = ff(20);
  45.     myPoint.y = ff(50);
  46.     
  47.     aViewPort = GXNewWindowViewPort(sampleWindow);
  48.     SetDefaultViewPort(aViewPort);
  49.     
  50.     runLengths[0] = 4;
  51.     runLengths[1] = 7;
  52.     len = runLengths[0] + runLengths[1];
  53.     
  54.     textPtrs[0] = romanString;
  55.     textPtrs[1] = &arabicString[0];
  56.     
  57.     romanStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(60), 0, nil, nil, 0, nil);
  58.     arabicStyle = NewLayoutStyle((char *) "\pBaghdad Plain", ff(60), 0, nil, nil, 0, nil);
  59.     
  60.     styleArray[0] = romanStyle;
  61.     styleArray[1] = arabicStyle;
  62.     
  63.     layout = GXNewLayout(
  64.         2, runLengths, (void *)textPtrs,
  65.         2, runLengths, styleArray,
  66.         1, &len, &level,
  67.         nil, &myPoint);
  68.     GXDrawShape(layout);
  69.     
  70.     caret = GXGetLayoutCaret(layout, 4, gxHighlightStraight, gxSplitCaretType, nil);
  71.     GXDrawShape(caret);
  72.     
  73.     GXMoveShape(layout, 0, ff(75));
  74.     GXDrawShape(layout);
  75.     GXGetLayoutCaret(layout, 4, gxHighlightStraight, gxLeftRightKeyboardCaret, caret);
  76.     GXDrawShape(caret);
  77.     
  78.     GXMoveShape(layout, 0, ff(75));
  79.     GXDrawShape(layout);
  80.     GXGetLayoutCaret(layout, 4, gxHighlightStraight, gxRightLeftKeyboardCaret, caret);
  81.     GXDrawShape(caret);
  82.     
  83.     GXDisposeShape(caret);
  84.     GXDisposeShape(layout);
  85.     GXDisposeStyle(arabicStyle);
  86.     GXDisposeStyle(romanStyle);
  87.     GXDisposeViewPort(aViewPort);
  88.     }    /* main */
  89.